package com.immediatus.engine.contracts;

import java.util.Comparator;


public interface IModifier<T>{

    public static final Comparator<IModifier<?>> MODIFIER_COMPARATOR_DURATION_DESCENDING = new Comparator<IModifier<?>>(){
        @Override
        public int compare(final IModifier<?> modifierA_, final IModifier<?> modifierB_){
            final float durationA = modifierA_.getDuration();
            final float durationB = modifierB_.getDuration();

            if (durationA < durationB){
                return 1;
            } else if (durationA > durationB){
                return -1;
            } else{
                return 0;
            }
        }
    };

    public void reset();

    public boolean isFinished();

    public boolean isRemoveWhenFinished();

    public void setRemoveWhenFinished(final boolean removeWhenFinished_);

    public IModifier<T> deepCopy();

    public float getSecondsElapsed();

    public float getDuration();

    public float onUpdate(final float secondsElapsed_, final T item_);

    public void addModifierListener(final IModifierListener<T> listener_);

    public boolean removeModifierListener(final IModifierListener<T> listener_);


    public static interface IModifierListener<T>{
        public void onModifierStarted(final IModifier<T> pModifier, final T pItem);

        public void onModifierFinished(final IModifier<T> pModifier, final T pItem);
    }
}
